import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { eventrecordVO, eventrecordForm, eventrecordQuery } from '@/api/event/eventRecord/types';

/**
 * 查询事件记录列表
 * @param query
 * @returns {*}
 */

export const listeventrecord = (query): AxiosPromise<eventrecordVO[]> => {
  return request({
    url: '/event/eventRecord/list',
    method: 'get',
    params: query
  });
};

export const listCommeneventrecord = (query): AxiosPromise<eventrecordVO[]> => {
  return request({
    url: '/event/eventRecord/commonlist',
    method: 'get',
    params: query
  });
};

/**
 * 查询事件记录详细
 * @param eventRecordId
 */
export const geteventrecord = (eventRecordId: string | number): AxiosPromise<eventrecordVO> => {
  return request({
    url: '/event/eventRecord/' + eventRecordId,
    method: 'get'
  });
};

/**
 * 新增事件记录
 * @param data
 */
export const addeventrecord = (data: eventrecordForm) => {
  return request({
    url: '/event/eventRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改事件记录
 * @param data
 */
export const updateeventrecord = (data: eventrecordForm) => {
  return request({
    url: '/event/eventRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除事件记录
 * @param eventRecordId
 */
export const deleventrecord = (eventRecordId: string | number | Array<string | number>) => {
  return request({
    url: '/event/eventRecord/' + eventRecordId,
    method: 'delete'
  });
};

/**
 * 查询关联工单
 * @param eventRecordId
 */
export const getworkorder = (eventRecordId: string | number)=> {
  return request({
    url: '/event/eventRecord/selectWorkOrderByEvent/' + eventRecordId,
    method: 'get'
  });
};

/**
 *事件生成工单
 * @param eventRecordId
 */
export const insertworkorder = (eventRecordId: string | number)=> {
  return request({
    url: '/event/eventRecord/inseretWorkOrderByEvent/' + eventRecordId,
    method: 'get'
  });
};

/**
 *事件处理
 */
export const handleeventresult = (data)=> {
  return request({
    url: '/event/eventRecord/handleEvent',
    method: 'post',
    data: data
  });
};

/**
 *事件处理
 */
export const inseretWorkOrderByEventUser = (data)=> {
  return request({
    url: '/event/eventRecord/inseretWorkOrderByEventUser',
    method: 'post',
    data: data
  });
};

/**
 *工单受理人列表
 * @param eventRecordId
 */
export const listworkorderacceptor = ()=> {
  return request({
    url: '/event/eventRecord/getWorkOrderAcceptorList',
    method: 'get'
  });
};
